﻿//-----------------------------------------------------------------
// 创建时间:  2008年11月6日
// 创建者  : WuGui.Yang
//-----------------------------------------------------------------
using System; 
using System.Data;
using System.Data.SqlClient;
using System.Runtime.Serialization;
using System.Collections.Generic;

using Ruandao.MiniDac;

namespace Ruandao.Foundation.DataAccess
{
	/// <summary>
	/// Table [TagsContents] MiniDac Entity Class 
	/// </summary>
    public partial class TagIndexEntity : EntityBase<TagIndexEntity>
	{
        public int[] CachedContentIds
        {
            get { return TypeUtil.IntAarrayFromBytes(cachedContentIdsBytes); }
            set { cachedContentIdsBytes = TypeUtil.BytesFromIntArray(value); }
        }

        public static TagIndexEntity FetchByTags(int[] tagIds)
        {
            // 得到数量为8的整数数组，不够则补零，多的剪掉。
            int[] ids = new int[8];
            int i;
            for ( i = 0; i < tagIds.Length && i<8; i++)
            {
                ids[i] = tagIds[i];
            }
            int number = i;

            string condition = "WHERE " +
"TagNumber=" + number.ToString() + " AND " +
"TagId0=" + ids[0].ToString() + " AND " +
"TagId1=" + ids[1].ToString() + " AND " +
"TagId2=" + ids[2].ToString() + " AND " +
"TagId3=" + ids[3].ToString() + " AND " +
"TagId4=" + ids[4].ToString() + " AND " +
"TagId5=" + ids[5].ToString() + " AND " +
"TagId6=" + ids[6].ToString() + " AND " +
"TagId7=" + ids[7].ToString();

            return FindOneByCondition(condition);
        }

        static public List<TagIndexEntity> SearchSubTags(int[] tagIds)
        {
            throw new NotImplementedException();
        }


    }

}
